
// panel object
local PANEL = {};


/*------------------------------------
	initialize the playlist info
------------------------------------*/
function PANEL:Init( )

	// create the container
	self.Container = vgui.Create( "MXPlaylistInfo_Container", self );

end


/*------------------------------------
	layout the playlist info
------------------------------------*/
function PANEL:PerformLayout( )

	// size & position the container
	self.Container:SetPos( 0, 0 );
	self.Container:SetSize( self:GetWide(), self:GetTall() );

end


/*------------------------------------
	paint the playlist info
------------------------------------*/
function PANEL:Paint( )

	// all done
	return true;

end


/*------------------------------------
	show the playlist info
------------------------------------*/
function PANEL:ShowInfo( text )

	// pass to container
	self.Container:ShowInfo( text );

end


// define
derma.DefineControl( "MXPlaylistInfo", "", PANEL, "DPanel" );


// panel object
PANEL = {};


/*------------------------------------
	initialize the media info
------------------------------------*/
function PANEL:Init( )

	// create the label
	self.Label = vgui.Create( "MXLabel", self );
	// default position
	self.Label:SetPos( 0, self:GetTall() + 5 );
	
	// defaults
	self.AnimTime = 0;
	self.State = -1;

end


/*------------------------------------
	playlist info thinking
------------------------------------*/
function PANEL:Think( )

	// check if its time to animation
	if ( MXCurTime() > self.AnimTime && self.State != -1 ) then
	
		// set the next animation time
		self.AnimTime = MXCurTime() + 0.01;
		
		// default positions
		local x = self.Label.X;
		local y = self.Label.Y;
		
		// calculate the speed
		local speed = 1.4; /*( FrameTime() * 100 )*/
		
		// check if animation is vertical
		if ( self.State == 0 ) then
		
			// alter the Y position
			y = math.max( y - speed, 0 );
			
			// check if we've hit the top
			if ( y == 0 ) then
			
				// change the animation to horizontal
				self.State = 1;
				
				// delay the next animation
				self.AnimTime = MXCurTime() + 1;
				
			end
		
		// check if animation is horizontal
		elseif ( self.State == 1 ) then
		
			// minimum X position
			local min = ( self.Label:GetWide() + 10 ) * -1;
			
			// alter the X position
			x = math.max( x - speed, min );
			
			// check if we've hit the min position
			if ( x == min ) then
			
				// change the animation to reset
				self.State = 2;
				
				// delay the next animation sequence
				self.AnimTime = MXCurTime() + 1;
				
			end
		
		end
		
		// update the position
		self.Label:SetPos( x, y );
		
	end
	
end


/*------------------------------------
	paint the playlist info
------------------------------------*/
function PANEL:Paint( )

	// all done
	return true;

end


/* CUSTOM PANEL FUNCTIONS */


/*------------------------------------
	set the playlist info text
------------------------------------*/
function PANEL:ShowInfo( text )

	// reste the label position
	self.Label:SetPos( 5, self:GetTall() + 5 );
	
	// set the text
	self.Label:SetText( text );
	
	// resize
	self.Label:SizeToContents();
	
	// reset the animation state
	self.State = 0;
	
	// delay the next animation
	self.AnimTime = MXCurTime() + 0.1;

end

// define
derma.DefineControl( "MXPlaylistInfo_Container", "", PANEL, "DPanel" );
